"""
Project Name : api_automation_framework
File Name : delay_n.py
Author : lldhsds
Date : 2024/12/28 14:31
Description: /delay/{delay}, return a delayed response(max of 10 seconds).
"""

import requests
def get_delay(delay):
    """
    /delay/{delay}, return a delayed response(max of 10 seconds)
    :param delay:
    :retrun A delayed response.
    """
    url = f"http://httpbin.org/delay/{delay}"
    headers = {'accept': 'application/json'}
    response = requests.get(url, headers=headers)
    print(response.status_code)
    print(response.json())
    print(response.headers)

def post_delay(delay):
    """
    /delay/{delay}, return a delayed response(max of 10 seconds)
    :param delay:
    :retrun A delayed response.
    """
    url = f"http://httpbin.org/delay/{delay}"
    headers = {'accept': 'application/json'}
    response = requests.post(url, headers=headers)
    print(response.status_code)
    print(response.json())
    print(response.headers)


def put_delay(delay):
    """
    /delay/{delay}, return a delayed response(max of 10 seconds)
    :param delay:
    :retrun A delayed response.
    """
    url = f"http://httpbin.org/delay/{delay}"
    headers = {'accept': 'application/json'}
    response = requests.put(url, headers=headers)
    print(response.status_code)
    print(response.json())
    print(response.headers)

def patch_delay(delay):
    """
    /delay/{delay}, return a delayed response(max of 10 seconds)
    :param delay:
    :retrun A delayed response.
    """
    url = f"http://httpbin.org/delay/{delay}"
    headers = {'accept': 'application/json'}
    response = requests.patch(url, headers=headers)
    print(response.status_code)
    print(response.json())
    print(response.headers)

def delete_delay(delay):
    """
    /delay/{delay}, return a delayed response(max of 10 seconds)
    :param delay:
    :retrun A delayed response.
    """
    url = f"http://httpbin.org/delay/{delay}"
    headers = {'accept': 'application/json'}
    response = requests.delete(url, headers=headers)
    print(response.status_code)
    print(response.json())
    print(response.headers)

if __name__ == '__main__':
    get_delay(5)
    post_delay(5)
    put_delay(5)
    patch_delay(5)
    delete_delay(5)
